﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lidgren.Network;

namespace Network.Messages.FileTranser
{
    public class RequsetCopyFileMessage : NovaMessage
    {
        public RequsetCopyFileMessage() :
             base((ushort)CustomMessageType.RequestCopyFile)
        {
        }

        public string DirPath;
        public List<string> DirList = new List<string>();
        public List<string> FileList = new List<string>();
        public override void WritePayload(NetOutgoingMessage message)
        {
            base.WritePayload(message);
            message.Write(DirPath);

            message.Write(DirList.Count);
            foreach (var dir in DirList)
            {
                message.Write(dir);
            }
            message.Write(FileList.Count);
            foreach (var file in FileList)
            {
                message.Write(file);
            }
        }

        public override void ReadPayload(NetIncomingMessage message)
        {
            base.ReadPayload(message);
            DirPath = message.ReadString();
            DirList.Clear();
            FileList.Clear();
            int dirCount = message.ReadInt32();
            for (int i = 0; i < dirCount; i++)
            {
                DirList.Add(message.ReadString());
            }
            int fileCount = message.ReadInt32();
            for (int i = 0; i < fileCount; i++)
            {
                FileList.Add(message.ReadString());
            }
        }
    }
}
